﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace IM
{
    public partial class FormLogin : Form
    {
        private InterfaceRemota.IUsuario usuario;

        public FormLogin()
        {
            InitializeComponent();
            /*bool isVisivel = Environment.UserName.Equals("gustavo.bergamim");
            lbLogin.Visible = isVisivel;
            txtLogin.Visible = isVisivel;
            lblPorta.Visible = isVisivel;
            txtPorta.Visible = isVisivel;*/
            this.TopLevel = true;
        }

        private void FormLogin_Load(object sender, EventArgs e)
        {
            usuario = new Gerenciamento.UsuarioImpl();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            String login = "";
            if (txtLogin.Text.Length > 0)
            {
                login = txtLogin.Text.ToLower();
            }
            else
            {
                login = Environment.UserName;
            }

            String ip = "";
            if (txtServer.Text.Length > 0)
            {
                ip = txtServer.Text.ToLower();
            }
            else
            {
                ip = "localhost";
            }

            short porta = 0;
            if (txtPorta.Text.Length > 0)
            {
                porta = Convert.ToInt16(txtPorta.Text);
            }
            else
            {
                porta  = 8080;
            }
            usuario.Login = login;
            FormPrincipal principal = new FormPrincipal(usuario, this, ip, porta);
            principal.Show();
            this.Visible = false;
        }
    }
}
